package com.link.gateway.core.filter.visitstatistics.util;

import com.link.gateway.core.utils.YmlConstants;

/**
 * 接口统计需要用到的一些常量，
 * 通常是一些redis中的key或者hash结构中的field
 *
 * @author Li Yang
 */
public class VisitStatisticsConstants {

    public static final String API_VISIT_TYPE_VISIT = "visit";

    public static final String API_VISIT_TYPE_AUTH = "auth";

    public static final String Y = "Y";

    public static final String N = "N";

    /**
     * 获取登录用户redis key的前缀
     */
    public static final String TOKEN_KEY_PREFIX = "login_info_";
    /**
     * 获取登录用户信息的field
     */
    public static final String TOKEN_FIELD = "superset";
    /**
     * 接口频率记录的key
     */
    public static final String VISIT_STATISTICS_KEY = "visit_statistics_" + YmlConstants.getVisitLogEnv();
    /**
     * 写入日志时的topic字段
     */
    public static final String API_KAFKA_TOPIC = "apiVisitHistory";
    /**
     * 接口统计全局参数的key
     */
    public static final String API_STATISTICS_CONFIG_KEY = "api_statistics_config";
    /**
     * 功能状态
     */
    public static final String API_CONFIG_STATUS = "status";
    /**
     * 频率时间范围
     */
    public static final String API_CONFIG_LIMIT_TIME = "limitTime";
    /**
     * 单位时间预警请求数量
     */
    public static final String API_CONFIG_LIMIT_VISIT_NUM = "limitVisitNum";
    /**
     * 单位时间越权请求数量
     */
    public static final String API_CONFIG_LIMIT_AUTH_NUM = "limitAuthNum";
    /**
     * 是否发送短信预警
     */
    public static final String API_CONFIG_MSG_ALERT = "msgAlert";
    /**
     * 是否发送邮件预警
     */
    public static final String API_CONFIG_EMAIL_ALERT = "emailAlert";
    /**
     * 短信模板编码
     */
    public static final String API_CONFIG_MSG_EXAMPLE_CODE = "msgExampleCode";
    /**
     * 短信参数
     */
    public static final String API_CONFIG_MSG_PARAMS = "msgParams";
    /**
     * 短信类型
     */
    public static final String API_CONFIG_MSG_TYPE = "msgType";
    /**
     * 短信通知手机号
     */
    public static final String API_CONFIG_MSG_PHONES = "msgPhones";
    /**
     * 用来存储上次访问接口超频的报警时间的key，redis key
     */
    public static final String API_CONFIG_ALERT_TIME_INTERVAL = "alertTimeInterval";
    /**
     * 通知邮箱
     */
    public static final String API_CONFIG_EMAIL_ADDRS = "emailAddrs";
    /**
     * 是否启用访问限制
     */
    public static final String API_CONFIG_ACCESS_RESTRICTION = "accessRestriction";
    /**
     * 不记录的接口
     */
    public static final String API_CONFIG_NO_RECORD = "noRecord";
    /**
     * 特殊记录的url
     */
    public static final String API_CONFIG_SPECIAL_URL = "specialUrl";
    /**
     * 特殊url的时间间隔
     */
    public static final String API_CONFIG_SPECIAL_LIMIT_TIME = "specialLimitTime";
    /**
     * 特殊url的访问数量限制
     */
    public static final String API_CONFIG_SPECIAL_LIMIT_NUM = "specialLimitNum";
    /**
     * 特殊url的越权数量限制
     */
    public static final String API_CONFIG_SPECIAL_AUTH_NUM = "specialAuthNum";
    /**
     * 单独记录登录访问
     */
    public static final String API_LOGIN_LIST = "apiLoginList";
    /**
     * 登录访问的配置信息key
     */
    public static final String API_LOGIN_CONFIG = "apiLoginConfig";
    /**
     * 登录访问的配置信息field - 限制次数
     */
    public static final String API_LOGIN_LIMIT_NUM = "apiLoginLimitNum";
    /**
     * 登录访问的配置信息field - 单位时间
     */
    public static final String API_LOGIN_LIMIT_TIME = "apiLoginLimitTime";
    /**
     * 登录访问的配置信息field - 下次发出报警信息的时间
     */
    public static final String API_LOGIN_NEXT_ALERT_TIME = "apiLoginNextAlertTime";
    /**
     * 登录访问的配置信息field - 发出报警时间间隔
     */
    public static final String API_LOGIN_ALERT_TIME_INTERVAL = "apiLoginAlertTimeInterval";

    public static String[] getExcludePathPattern() {
        return EXCLUDE_PATH_PATTERN;
    }

    private static final String[] EXCLUDE_PATH_PATTERN = {
        "/base/user/publicKey",
        "/base/user/login",
        "/base/user/login2",
        "/base/user/dmslogin",
        "/base/user/mobileLogin",
        "/base/user/mpLogin",
        "/base/user/mockMpLogin",
        "/base/user/oauthToken",
        "/link/appVersion/query",
        "/link/appVersion/getAppVersionList",
        "/link/appManager/getAppList",
        "/link/appManager/getAppById",
        "/link/knowledge/queryKnowledgeById",
        "/link/product/queryShareProdById",
        "/base/user/refreshtoken",
        "/link/corpwx/access/**",
        "/link/corpwx/user_login/login",
        "/wxconsumer/auth/**",
        "/forgotpassword/**",
        "/queryByUserCode/**",
        "/error",
        "/link/sendResult/smsCallback",
        "/link/coupons/pcGetCoupon",
        "/link/coupons/showCoupons",
        "/link/coupons/newQueryById",
        "/link/saleActivity/newQueryById",
        "/link/odds/reffleInfo",
        "/link/saleActivity/reffle",
        "/link/coupons/getCoupons",
        "/link/coupons/queryByCoupons",
        "/link/guideproduct/queryById",
        "/link/coupons/productForCard",
        "/link/guideproduct/createGuideCode",
        "/link/coupons/clippingCoupons",
        "/link/phoneMsgs/getVerifyCode",
        "/link/collectRecord/getCodePic",
        "/link/mpmember/notify_url",
        "/api/**",
        "/superset/**",
        "/link/token/remove",
        "/link/login/getUserCtx",
        "/link/menu/queryCurrentMenuList",
        "/link/face/external/personcome",
        "/link/face/external/resetYoutu",
        "/link/service/newServiceReqlogOut",
        "/link/forum/queryShareById",
        "/base/user/checkMpUserLogin",
        "/link/coupons/queryCouponsByActivityId",
        "/link/coupons/scanCodeUseCoup",
        "/link/face/external/smartScreenPersonCome",
        "/link/thirdParty/getWeChatAuthUrl",
        "/link/thirdParty/getQQAuthUrl",
        "/link/thirdParty/wxBindDo",
        "/link/thirdParty/wxLoginDo",
        "/link/thirdParty/qqBindDo",
        "/link/thirdParty/qqLoginDo",
        "/link/thirdParty/login",
        "/link/thirdParty/getLoginUser",
        "/link/thirdParty/wxSecAuth",
        "/link/thirdParty/getWXRandomToken",
        "/link/knowledge/publicTreelist",
        "/link/knowledge/publicQueryByNode",
        "/link/knowledge/queryPublicKnowledgeByExamplePage",
        "/link/knowledge/queryPublicById",
        "/link/attachment/insertAttachment",
        "/link/thirdParty/thirdPartyAuthing"
    };
}
